stages:
  - lint
  - minify

minify:
  stage: minify
  script:
    - pip install python-minifier
    - for py in `find . -name "*.py"`; do echo "оптимизируем $py..."; pyminify --remove-literal-statements $py > $py.min; mv $py.min $py; done
    - git remote set-url origin $SECRET
    - git config --global user.email "carmakdoom@gmail.com"
    - git config --global user.name "CI Runner"
    - git checkout -B minified
    - git add .
    - git commit -m "Minified code"
    - git push origin minified --force
  rules:
    - if: $CI_COMMIT_BRANCH == "main"

lint:
  stage: lint
  script:
    - pip install ruff
    - ruff format .
    - git remote set-url origin $SECRET
    - git config --global user.email "carmakdoom@gmail.com"
    - git config --global user.name "CI Runner"
    - git checkout -B linted
    - git add .
    - git commit -m "Linted code"
    - git push origin linted --force
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  
